<template>
  <div class="side-toolbar">
    <div class="tool-item" @click="toCart">
      <el-badge :value="cartCount" :max="99">
        <i class="iconfont icon-cart"></i>
      </el-badge>
      <span>购物车</span>
    </div>
    <div class="tool-item" @click="toFavorites">
      <i class="iconfont icon-star"></i>
      <span>收藏</span>
    </div>
    <div class="tool-item" @click="toHistory">
      <i class="iconfont icon-history"></i>
      <span>足迹</span>
    </div>
    <div class="tool-item" @click="scrollToTop">
      <i class="iconfont icon-top"></i>
      <span>顶部</span>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const cartCount = ref(5)

const toCart = () => router.push('/cart')
const toFavorites = () => router.push('/user/favorites')
const toHistory = () => router.push('/user/history')
const scrollToTop = () => window.scrollTo({ top: 0, behavior: 'smooth' })
</script>

<style lang="scss" scoped>
.side-toolbar {
  position: fixed;
  right: 20px;
  bottom: 100px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 15px;

  .tool-item {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);

    &:hover {
      transform: translateX(-5px);
      background: #ff4d4f;
      
      i, span {
        color: #fff;
      }
    }

    i {
      font-size: 24px;
      color: #666;
      margin-bottom: 4px;
    }

    span {
      font-size: 12px;
      color: #666;
    }
  }
}
</style>
